﻿package net.wangit.dev.settings;

import net.wangit.Unit;
import net.wangit.context.ActionContext;
import net.wangit.support.UnitInterceptor;

public class SystemUI implements UnitInterceptor {

	public SystemUI() {
	}

	public String intercept(ActionContext ac, Unit unit) throws Exception {
		unit.getElement("javaversion").setCustom(
				System.getProperty("java.version"));
		unit.getElement("javavendor").setCustom(
				System.getProperty("java.vendor"));
		unit.getElement("javahome").setCustom(System.getProperty("java.home"));
		unit.getElement("jvmversion").setCustom(
				System.getProperty("java.vm.version"));
		unit.getElement("jvmvendor").setCustom(
				System.getProperty("java.vm.vendor"));
		unit.getElement("jvmname")
				.setCustom(System.getProperty("java.vm.name"));
		unit.getElement("classversion").setCustom(
				System.getProperty("java.class.version"));
		unit.getElement("classpath").setCustom(
				System.getProperty("java.class.path"));
		String libraryPath = System.getProperty("java.library.path");
		libraryPath = libraryPath.replaceAll(";", "<BR>");
		unit.getElement("librarypath").setCustom(libraryPath);
		unit.getElement("tmpdir").setCustom(
				System.getProperty("java.io.tmpdir"));
		unit.getElement("osname").setCustom(System.getProperty("os.name"));
		unit.getElement("osversion")
				.setCustom(System.getProperty("os.version"));
		unit.getElement("osarch").setCustom(System.getProperty("os.arch"));
		unit.getElement("username").setCustom(System.getProperty("user.name"));
		unit.getElement("usercountry").setCustom(
				System.getProperty("user.country"));
		unit.getElement("userlanguage").setCustom(
				System.getProperty("user.language"));
		unit.getElement("userdir").setCustom(System.getProperty("user.dir"));
		unit.getElement("usertimezone").setCustom(
				System.getProperty("user.timezone"));
		unit.getElement("fileencoding").setCustom(
				System.getProperty("file.encoding"));
		return unit.write(ac);
	}
}
